Import Libraries


In [1]:
import cv2

In [2]:
import matplotlib.pyplot as plt
%matplotlib inline

Read image and Check inspect values of image at different locations


In [3]:
img_RGB = cv2.imread('demo1.jpg')

In [4]:
plt.imshow(cv2.cvtColor(img_RGB, cv2.COLOR_BGR2RGB))


Out[4]:
<matplotlib.image.AxesImage at 0x7fd779263eb8>

In [5]:
print('Shape_RGB:', img_RGB.shape)


Shape_RGB: (1080, 1920, 3)

In [6]:
print('Type_RGB:', img_RGB.dtype)


Type_RGB: uint8

RGB pixel intensity 0-255


In [7]:
print('RGB intensity at 300,250:',img_RGB[300,250])


RGB intensity at 300,250: [80 72 32]

RGB line intensity 0-255


In [8]:
img_RGB_lineintensity = img_RGB[600]

In [9]:
plt.plot(img_RGB_lineintensity)


Out[9]:
[<matplotlib.lines.Line2D at 0x7fd779155e48>,
 <matplotlib.lines.Line2D at 0x7fd779155fd0>,
 <matplotlib.lines.Line2D at 0x7fd77915b240>]

Similarly, image values can be inspected for a Gray image. Gray image will be more prefered as it will decrease 3 RGB pixels to just one gray and hence simplify processing. It will also help in standardizing from large image color types.